package com.wtwd.device.controller;

import com.wtwd.device.model.entity.HeartRateList;
import com.wtwd.device.model.entity.SetBloodOxygenWarning;
import com.wtwd.device.model.entity.SetHeartRateWarning;
import com.wtwd.device.model.vo.FrequencyAndValueVo;
import com.wtwd.device.model.vo.RespEntity;
import com.wtwd.device.model.vo.ResultVO;
import com.wtwd.device.service.HeartRateListService;
import com.wtwd.device.service.SetHeartRateWarningService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "心率模块相关")
@RestController
@RequestMapping("/heart-rate")
public class HeartRateController {
    @Autowired
    private HeartRateListService heartRateListService;


    @Autowired
    private SetHeartRateWarningService setHeartRateWarningService;

    @ApiOperation(value = "获取心率列表可选项值", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型 1-高心率 2-低心率 3-运动心率 不填默认查所有数据", dataType = "int"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = HeartRateList.class)
    })
    @RequestMapping(value = "/getHeartRateList" , method = RequestMethod.GET)
    public ResultVO getHeartRateList(@RequestParam(value = "type",defaultValue = "") Byte type){
        List<HeartRateList> heartRateList = heartRateListService.getHeartRateList(type);
        return ResultVO.success(heartRateList);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceId", value = "设备ID", dataType = "long"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = FrequencyAndValueVo.class)
    })
    @ApiOperation(value = "通过设备id获取当前设备设置的心率值")
    @GetMapping(value = "/getHeartRateWarningByDeviceId/{deviceId}")
    public ResultVO getHeartRateWarningByDeviceId(@PathVariable("deviceId") Long deviceId){
        FrequencyAndValueVo setBloodOxygenWarning = setHeartRateWarningService.getHeartRateWarningByDeviceId(deviceId);
        return ResultVO.success(setBloodOxygenWarning);
    }
}
